#pragma once
#include "DXAMLCommon.h"
#include "CBitmapSource.h"



class CWriteableBitmap :
	public CBitmapSource
{

protected: 
	CWriteableBitmap(CCoreServices * pCore);
protected: 
	virtual ~CWriteableBitmap();
private: 
	virtual HRESULT InitInstance();
public: 
	HRESULT Create(void * pvPixels, XINT32 nWidth, XINT32 nHeight);
	static HRESULT Create(CDependencyObject * * ppObject, CREATEPARAMETERS * pCreate);
	HRESULT Invalidate();
	HRESULT CopyPixels(void * pvPixels);
	virtual XINT32 GetPixelWidth();
	virtual XINT32 GetPixelHeight();
	virtual HRESULT EnsureAndUpdateHardwareResources(HWTextureManager * pTextureManager, CRenderTarget * pRenderTarget, SurfaceCache * pSurfaceCache);
	virtual HRESULT OnDownloadImageAvailable(struct IImageAvailableResponse * pResponse);
private: 
	void Reset();
	HRESULT CreateSurface(XINT32 * pPixels, struct IPALSurface * * ppSurface);
	XINT32 * m_pPixels;
	XUINT32 m_nWidth;
	XUINT32 m_nHeight;
	XUINT32 m_nLength;
	XUINT32 m_contentInvalid;
};